package com.junxonline.common.exception;

import java.io.Serializable;

/**
 * 前2位数为系统模块编号,后2位为功能模块编号,最后3位为具体业务异常编号 ,共7位必须保持唯一
 * 未知错误：0000000
 * 系统公共 00
 *
 * @author lijx
 * @ClassName: CommonBizException
 * @Description: 系统异常类
 */

public class CommonBizException extends BizException implements Serializable {

    /**
     * 登录认证失败
     */
    public static final CommonBizException LOGIN_AUTH_IS_ERROR = new CommonBizException("401", "登录认证失败");

    /**
     * 登录认证失败
     */
    public static final CommonBizException PERMISSION_AUTH_IS_ERROR = new CommonBizException("403", "权限认证失败");

    /**
     * 系统错误
     */
    public static final CommonBizException SYSTEM_ERROR = new CommonBizException("0000000", "系统错误");

    /**
     * 参数错误
     */
    public static final CommonBizException SYSTEM_PARAM_ERROR = new CommonBizException("0000001", "参数错误");

    /**
     * Token认证失败
     */
    public static final CommonBizException TOKEN_AUTH_IS_ERROR = new CommonBizException("0000003", "Token认证失败");

    /**
     * 用户名不存在
     */
    public static final CommonBizException ACCOUNT_IS_NOT_FINDED = new CommonBizException("0000004", "用户名不存在");

    /**
     * 用户名或密码不正确
     */
    public static final CommonBizException ACCOUNT_OR_PASSWORD_IS_ERROR = new CommonBizException("0000005", "用户名或密码不正确");

    /**
     * Redis连接失败
     */
    public static final CommonBizException REDIS_IS_NOT_CONNECTION = new CommonBizException("0000006", "Redis连接失败");

    /**
     * 只能给岗位设置权限
     */
    public static final CommonBizException POSITION_SET_PERMISSION_ERROR = new CommonBizException("0000007", "只能给岗位设置权限");


    public CommonBizException() {
    }

    public CommonBizException(String code, String msgFormat, Object... args) {
        super(code, msgFormat, args);
    }

    public CommonBizException(String code, String msg) {
        super(code, msg);
    }

    /**
     * 实例化异常
     *
     * @param msgFormat
     * @param args
     * @return
     */
    @Override
    public CommonBizException newInstance(String msgFormat, Object... args) {
        return new CommonBizException(this.code, msgFormat, args);
    }

}
